home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 2000
/
MacHack 2000.toast
/
pc
/
The Hacks
/
NoShitSherlock
/
NoShitSherlock Engine.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-06-23
|
964b
|
37 lines
#include <Applescript.h>
#include <OSA.h>
#include <string.h>
#include <stdio.h>
Boolean quitting = false;
char *script = "tell application \"Finder\" \r\
activate \r\
try \r\
set x to display dialog \"Enter a search string, Sherlock\" ¬\r\
default answer \".txt\" default button \"OK\" \r\
set y to text returned of x \r\
select (every file whose name contains y) in front window \r\
on error \r\
end try \r\
end tell \r";
void main() {
ComponentInstance instance = 0;
AEDesc desc = { typeNull, 0 };
OSAID osaid = kOSANullScript;
MaxApplZone();
InitGraf(&qd.thePort);
instance = OpenDefaultComponent(kOSAComponentType, typeAppleScript);
if (!instance) goto CLEANUP;
if (AECreateDesc(typeChar, script, strlen(script), &desc)) goto CLEANUP;
if (OSACompileExecute(instance, &desc, kOSANullScript,
kOSAModeAlwaysInteract, &osaid)) SysBeep(7);
CLEANUP:
if (osaid) OSADispose(instance, osaid);
AEDisposeDesc(&desc);
CloseComponent(instance);
}